import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:shen_nai/app/user_controller.dart';
import 'package:shen_nai/routes/app_routes.dart';

class MinePage extends StatefulWidget {
  const MinePage({Key? key}) : super(key: key);

  @override
  State<MinePage> createState() => _MinePageState();
}

class _MinePageState extends State<MinePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.transparent,
        elevation: 0,
        toolbarHeight: 100,
        titleSpacing: 0,
        centerTitle: false,
        title: Container(
            margin: EdgeInsets.only(left: 20),
            child: GetBuilder<UserController>(
              init: UserController(),
              builder: (controller) {
                return Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    const SizedBox(
                      height: 10,
                    ),
                    Text(
                      controller.jurisdiction > 1 ? '普通用户' : '管理员',
                      style: TextStyle(fontSize: 14),
                    ),
                    const SizedBox(
                      height: 5,
                    ),
                    Text(controller.username, style: TextStyle(fontSize: 14))
                  ],
                );
              },
            )),
        //primary: true,
        flexibleSpace: Image.asset('assets/images/mine_bg.png',
            height: MediaQuery.of(context).padding.top + 100,
            width: double.infinity,
            fit: BoxFit.cover),
      ),
      body: Column(
        children: [
          Container(
            height: 100,
            // alignment: Alignment.centerLeft,
            // margin: const EdgeInsets.only(top: 30, left: 24),
            // child: const Text('常用功能',
            //     style: TextStyle(
            //         color: Colors.white,
            //         fontSize: 18,
            //         fontWeight: FontWeight.bold)),
          ),
          // ListTile(
          //   onTap: () {},
          //   leading: Image.asset(
          //     'assets/images/mine_phone.png',
          //     width: 24,
          //     height: 24,
          //   ),
          //   title: Transform(
          //       transform: Matrix4.translationValues(-22, 0.0, 0.0),
          //       child: Text(
          //         '修改手机号',
          //         style: TextStyle(color: Colors.white, fontSize: 16),
          //       )),
          //   contentPadding: EdgeInsets.symmetric(horizontal: 18),
          //   trailing: Icon(
          //     Icons.keyboard_arrow_right,
          //     color: Color(0xff999999),
          //   ),
          // ),
          // ListTile(
          //   onTap: () {},
          //   leading: Image.asset(
          //     'assets/images/update_password.png',
          //     width: 24,
          //     height: 24,
          //   ),
          //   title: Transform(
          //       transform: Matrix4.translationValues(-22, 0.0, 0.0),
          //       child: Text(
          //         '修改密码',
          //         style: TextStyle(color: Colors.white, fontSize: 16),
          //       )),
          //   contentPadding: EdgeInsets.symmetric(horizontal: 18),
          //   trailing: Icon(
          //     Icons.keyboard_arrow_right,
          //     color: Color(0xff999999),
          //   ),
          // )
          SizedBox(
            height: 40,
            width: MediaQuery.of(context).size.width - 30,
            child: TextButton(
              onPressed: () {
                Get.find<UserController>().clear();
                Get.offAllNamed(AppRoute.LOGIN);
              },
              child: const Text(
                '退出登陆',
                style: TextStyle(
                    color: Colors.white,
                    fontSize: 14,
                    fontWeight: FontWeight.bold),
              ),
              style: TextButton.styleFrom(
                  shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(5),
                      side: const BorderSide(
                          width: 1, color: Color(0xff3486F7)))),
            ),
          )
        ],
      ),
    );
  }
}
